#include <iostream>

using namespace std;

//static const int N = 8;

int a[8], b[15], c[15];
char q[8][8];

int qu(int line)
{
	int d = 0;
	for(int i=0; i<8; i++)	//column
	{
		if(a[i]==0 && b[i+line]==0 && 0==c[line-i+7])
		{
			if(line == 7)
			{
				q[line][i] = '@';
				for(int s = 0;s<8;s++)
				{
					for(int j = 0;j<8;j++)
					{
						cout<<q[s][j]<<" ";
					}
					cout<<endl;
				}
				cout<<endl;
				q[line][i] = '*';
				return 1;
			}
			a[i] = 1;
			b[i + line] = 1;
			c[line-i+7] = 1;
			q[line][i] = '@';
			d += qu(line+1);
			q[line][i] = '*';
			a[i] = 0;
			b[i + line] = 0;
			c[line-i+7] = 0;
		}
	}
	return d;
}

int main()
{
	for(int i=0; i<8; i++)
	{
		a[i] = 0;
		for(int j=0; j<8; j++)
		q[i][j] = '*';
	}
	for(int i=0; i<15; i++)
		b[i]=c[i]=0;

	cout<<qu(0)<<endl;
}
